package com.wxisme.composite;

import java.util.ArrayList;
import java.util.List;


public interface AbstractFile {
	void killVirus();
}


class ImageFile implements AbstractFile {
	private String name;
	
	public ImageFile(String name) {
		super();
		this.name = name;
	}

	@Override
	public void killVirus() {
		System.out.println("---查杀图像文件"+name);
	}
	
}
class TextFile implements AbstractFile {
	private String name;
	
	public TextFile(String name) {
		super();
		this.name = name;
	}
	
	@Override
	public void killVirus() {
		System.out.println("---查杀文本文件"+name);
	}
}
class VideoFile implements AbstractFile {
	private String name;
	
	public VideoFile(String name) {
		super();
		this.name = name;
	}
	
	@Override
	public void killVirus() {
		System.out.println("---查杀视频文件"+name);
	}
}

class Folder implements AbstractFile {
	private String name;
	private List<AbstractFile> list = new ArrayList<AbstractFile>();
	
	public Folder(String name) {
		super();
		this.name = name;
	}

	public void add(AbstractFile file){
		list.add(file);
	}
	public void remove(AbstractFile file){
		list.remove(file);
	}
	public AbstractFile getChild(int index){
		return list.get(index);
	}

	@Override
	public void killVirus() {
		System.out.println("---查杀文件夹"+name);
		
		for (AbstractFile file : list) {
			file.killVirus();
		}
		
	}
	
}

